/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is Forte for Java, Community Edition. The Initial
* Developer of the Original Code is Sun Microsystems, Inc. Portions
* Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.projects;
import java.io.File;
import javax.swing.JFileChooser;
import org.openide.util.NbBundle;
/**
* Class SystemIniPanel that choose system file of other environment.
* It is then used for mount jar and zip files into repository.
* For example it is colled by ProjectInfoJBuld
* @author Petr Zajac
*/
public class SystemIniPanel extends javax.swing.JPanel {
private JFileChooser fileChooser = null;
// private File selectedFile = null ;
private String fileChooserMain = null ;
/** Default File
*/
private File currentFile = null;
/** Creates new form SystemIniPanel.
* @param fileLabel description about file which will be choosed
* @param fileChooser dialog for choosing system file
* @param fileChooserMain Title for param fileChooser
*/
public SystemIniPanel (String fileLabel,
JFileChooser fileChooser,
String fileChooserMain,
File currentFile) {
initComponents ();
this.fileChooser = fileChooser;
this.fileLabel.setText ( fileLabel );
if (currentFile != null ) {
this.jTextField1.setText (currentFile.getAbsolutePath ());
}
this.currentFile = currentFile;
this.fileChooserMain = fileChooserMain;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
private void initComponents () {
setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints1;
jTextField1 = new javax.swing.JTextField ();
jTextField1.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets (0, 8, 8, 4);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints1.weightx = 0.2;
add (jTextField1, gridBagConstraints1);
jButton1 = new javax.swing.JButton ();
jButton1.setText (NbBundle.getBundle(SystemIniPanel.class).getString("CTL_ButtonBrowse"));
jButton1.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
jButton1ActionPerformed (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 1;
gridBagConstraints1.gridwidth = 2;
gridBagConstraints1.insets = new java.awt.Insets (0, 4, 8, 8);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST;
add (jButton1, gridBagConstraints1);
fileLabel = new javax.swing.JLabel ();
fileLabel.setText ("ffff"); // NOI18N
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.insets = new java.awt.Insets (8, 8, 8, 8);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
add (fileLabel, gridBagConstraints1);
}
/** choose file
*/
private void jButton1ActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// Add your handling code here:
if (currentFile != null ) {
fileChooser.setCurrentDirectory (currentFile.getParentFile ());
}
fileChooser.showOpenDialog (this) ;
currentFile = fileChooser.getSelectedFile ();
if (currentFile != null ) {
jTextField1.setText (currentFile.getAbsolutePath ());
}
}//GEN-LAST:event_jButton1ActionPerformed
private void jTextField1ActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
// Add your handling code here:
}//GEN-LAST:event_jTextField1ActionPerformed
/** get selected system file
* @return choosed file or null if it isn't choosed
*/
public File getSelectedFile () {
return currentFile ;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField jTextField1;
private javax.swing.JButton jButton1;
private javax.swing.JLabel fileLabel;
// End of variables declaration//GEN-END:variables
}
/*
* Log
* 3 Gandalf 1.2 1/15/00 Martin Ryzl localization
* 2 Gandalf 1.1 1/14/00 Petr Zajac Bundles added
* 1 Gandalf 1.0 1/3/00 Martin Ryzl
* $
*/